home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / More Source / C⁄C++ / picture / pict.c < prev    next >
C/C++ Source or Header  |  1993-09-23  |  2KB  |  89 lines

  1. //    Copyright 1993 Ralph Gonzalez
  2.  
  3. /*
  4. *    FILE:        pict.c
  5. *    AUTHOR:        R. Gonzalez
  6. *    CREATED:    November 7, 1990
  7. *
  8. *    generic pict application methods.  You should define a single
  9. *    object of a class descending from Generic_Pict in your application,
  10. *    and your main() function should simply send this object a run()
  11. *    message.
  12. *
  13. *   REVISED:         November 7, 1991
  14. *   AUTHOR:          Donald C. Snow
  15. *   CHANGES:
  16. *
  17. *    eliminated the one instance of conditional compilation in 
  18. *    the code by having all derived screen header files define 
  19. *    "SCREEN" to something appropraite. Thus, new SCREEN, as 
  20. *    opposed to, conditionally, new Mac_Screen or 
  21. *    new PC_Screen. 
  22. */
  23.  
  24.  
  25. # include    "pict.h"
  26. # include    "error.h"
  27.  
  28. #ifdef THINK_C
  29. #include "macscrn.h"
  30. #endif
  31.  
  32. #ifdef TURBO_C
  33. #include "pcscrn.h"
  34. #endif
  35.  
  36. #ifdef __GNUG__
  37. #include "xscrn.h"
  38. #endif
  39.  
  40. Error    *gerror;        // global to report errors
  41.  
  42. // # include    <stdio.h>    // to allow stdio in pict application
  43.  
  44. /******************************************************************
  45. *    initialize
  46. ******************************************************************/
  47. Generic_Pict::Generic_Pict(void)
  48. {
  49.     double    aspect;
  50.  
  51. //    printf("\n");    // activate Think C console first to enable stdio
  52.  
  53.     gerror = new Error;
  54.     screen = new SCREEN;
  55. //    screen constructor should do this, but just to be sure: 
  56.     aspect = screen->get_device_aspect_ratio();
  57.     screen->set_normalized_frame(0.,0.,2.,2./aspect); 
  58.  
  59.     backdrop = new Backdrop_Projector;
  60.     backdrop->set_screen(screen); 
  61. }
  62.  
  63. /******************************************************************
  64. *    run - override freely
  65. *    If stdio is enabled as mentioned above, then the graphics
  66. *    windows are supplemented with a console for text i/o.  Send
  67. *    overlap() and clear() messages to projectors to bring their
  68. *    associated windows back to the front after console i/o.  This
  69. *    assumes that stdio calls automatically bring the console to the
  70. *    front, as is the case with Think C.
  71. ******************************************************************/
  72. void    Generic_Pict::run(void)
  73. {
  74.     screen->wait();
  75. }
  76.  
  77. /******************************************************************
  78. *    destroy
  79. ******************************************************************/
  80. Generic_Pict::~Generic_Pict(void)
  81. {
  82.     delete backdrop; 
  83.     delete screen;
  84.     delete gerror;
  85. }
  86.  
  87.     
  88.     
  89.